package ai.people.netmon.framework.businessenum.warning;

import java.util.Arrays;
import java.util.Optional;

/**
 * 预警导出文档类型
 *
 * @author 李冠男
 * @date 2022/5/31 15:57
 */
public enum WarningExportDocumentTypeEnum {

    /**
     * word
     */
    WORD(1, "word"),
    /**
     * pdf
     */
    PDF(2, "pdf"),
    /**
     * excel
     */
    EXCEL(3, "excel"),
    ;

    private final int code;

    private final String name;

    WarningExportDocumentTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static WarningExportDocumentTypeEnum parseCode(Integer code){
        Optional<WarningExportDocumentTypeEnum> first = Arrays.stream(WarningExportDocumentTypeEnum.values()).filter(o -> o.getCode() == code).findFirst();
        if(first.isPresent()){
            return first.get();
        }
        return null;
    }
}
